/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */
#ifndef _APP_BT_H_
#define _APP_BT_H_

#include <stdint.h>

#ifndef BT_BD_ADDR_LEN
#define BT_BD_ADDR_LEN     6
#endif

typedef enum
{
    APP_BT_AVRCP_CMD_PLAY = 0,
    APP_BT_AVRCP_CMD_PAUSE,
    APP_BT_AVRCP_CMD_FORWARD,
    APP_BT_AVRCP_CMD_BACKWARD,
    APP_BT_AVRCP_CMD_FAST_FORWARD,
    APP_BT_AVRCP_CMD_REWIND,
    APP_BT_AVRCP_CMD_STOP,
    APP_BT_AVRCP_CMD_MAX
} app_avrcp_cmd_type_t;

typedef enum {
    APP_BT_PAIRED,
    APP_BT_A2DP_CONNECTED,
    APP_BT_A2DP_DISCONNECTED,
    APP_BT_A2DP_CONNECTING,
    APP_BT_A2DP_LINK_LOSS,
    APP_BT_A2DP_PLAY_STATUS_STOPPED,
    APP_BT_A2DP_PLAY_STATUS_PLAYING,
    APP_BT_A2DP_PLAY_STATUS_PAUSEED,
    APP_BT_AVRCP_STATUS_PAUSEED,
    APP_BT_AVRCP_STATUS_STOPPED,
    APP_BT_AVRCP_STATUS_PLAYING,
    APP_BT_A2DP_VOLUME_CHANGE,
    APP_BT_A2DP_CMD,
} app_bt_event_t;

typedef union app_bt_param {
    struct bt_paired_param {
        uint8_t remote_addr[BT_BD_ADDR_LEN];
    } paired;

    struct bt_a2dp_conn_param {
        uint8_t remote_addr[BT_BD_ADDR_LEN];
    } a2dp_conn;

    struct bt_a2dp_cmd_param {
        app_avrcp_cmd_type_t cmd;
    } a2dp_cmd;

    struct bt_a2dp_vol_change_param {
        uint8_t volume;     
    } a2dp_vol;
} app_bt_param_t;

typedef void (*app_bt_callback_t)(app_bt_event_t event, app_bt_param_t *param);

int app_bt_init(void);

int app_bt_a2dp_init(void);

int app_bt_gap_set_scan_mode(int enable);

int app_bt_gap_set_device_name(char *name);

int app_bt_a2dp_connect(uint8_t remote_addr[BT_BD_ADDR_LEN]);

int app_bt_a2dp_disconnect(uint8_t remote_addr[BT_BD_ADDR_LEN]);

int app_bt_avrcp_send_passthrouth_cmd(app_avrcp_cmd_type_t cmd_type);

int app_bt_avrcp_change_vol(uint8_t vol);

int app_bt_register_cb(app_bt_callback_t callback);

int app_bt_a2dp_get_status(void);

int bt_init(void);

int bt_open(void);

int bt_close(void);

#endif